/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.eventos.bc;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.cip.esymons.eventos.be.Preevento;
import org.cip.esymons.eventos.be.TarifarioEvento;

/**
 *
 * @author oscar
 */
@Stateless
public class TarifarioEventoFacade implements TarifarioEventoFacadeLocal {
    @PersistenceContext
    private EntityManager em;

    public void create(TarifarioEvento tarifarioEvento) {
        em.persist(tarifarioEvento);
    }

    public void edit(TarifarioEvento tarifarioEvento) {
        em.merge(tarifarioEvento);
    }

    public void remove(TarifarioEvento tarifarioEvento) {
        em.remove(em.merge(tarifarioEvento));
    }

    public TarifarioEvento find(Object id) {
        return em.find(TarifarioEvento.class, id);
    }

    public List<TarifarioEvento> findAll() {
        return em.createQuery("select object(o) from TarifarioEvento as o").getResultList();
    }

    public List<TarifarioEvento> tarifariosPorEvento(Preevento preEvento) {
        return em.createQuery("select object(o) from TarifarioEvento as o where o.preCodigo=?1").setParameter(1,preEvento).getResultList();
    }

}
